package com.bit.demo.mybatisdemo.controller;


import com.bit.demo.mybatisdemo.model.UserInfo;
import com.bit.demo.mybatisdemo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping("/user")
@RestController
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping("/getAllUser")
    public List<UserInfo> getAllUser(){
        return userService.getAllUser();
    }
    @RequestMapping("/getUserById")
    public UserInfo getUserById(Integer id){
        return userService.getUserById(id);
    }

    /**
     * 登录
     * @param userName
     * @param password
     * @return true 登录成功，false 登录失败
     */
    @RequestMapping("/login")
    public boolean login(String userName,String password){
        UserInfo userInfo = userService.login(userName,password);
        return userInfo!=null;
    }
}
